<div class="header" id="h_nowosci"><a href="index.php">Nowości</a></div>
<?php
foreach($this->data as $product):
    $productLink = "product.php?action=browse&id={$product['id']}";
?>

<div class="news">
        <a href="<?=$productLink;?>">
            <img class="cover" src="<?=$product['coverURL'];?>" width="109" alt="<?=$product['title'];?>" />
        </a>
	<p class="title"><a href="<?=$productLink?>"><?=$product['title'];?></a></p>

	<p class="rating<?=$product['grade'];?>"><?=$product['grade'] == '' ? 'Brak ocen' : '';?></p>
	<p class="price"><?=$product['price'];?> zł</p>
	<p class="description"><?=$product['description'];?></p>
	<p class="more"><a href="<?=$productLink;?>">więcej  ></a></p>
</div>
<?php
endforeach;
?>
<div id="pages">
        <?php
            $minPage = max(array($this->selectedPage - 5, 1));
            $maxPage = min(array($this->selectedPage + 10 - ($this->selectedPage - $minPage), $this->pageCount));
            
            if ($selectedPage > 1):
            ?>
                <a class="page_number" href="index.php?page=<?=$this->selectedPage - 1;?>"><</a>
            <?php
            endif;
            for ($i = $minPage; $i < $maxPage; $i++)
            {
                if ($i == $this->selectedPage) :
                ?>
                    <span class='page_number'><?=$this->selectedPage;?></span>
                <?php
                endif;
                if ($i != $this->selectedPage) :
                ?>
                   <a class='page_number' href='index.php?page=<?=$i;?>'><?=$i;?></a>
                <?php
                endif;
                    
            }
            if ($maxPage < $this->pageCount) :
            ?>
                   <span class='page_number'>...</span>
            <?php
            endif;
            if ($this->selectedPage + 1 < $this->pageCount) :
         ?>
            <a class="page_number" href="index.php?page=<?=$this->selectedPage + 1;?>">></a>
         <?php
            endif;
	?>
</div>